﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using RIA.ViewModel;

namespace RIA.NTiersApp.Views
{
    public partial class CustomerDetails : Page
    {
        private RIA.ViewModel.CustomerDetailsViewModel customerVM = null;
        public CustomerDetails ()
        {
            InitializeComponent ();
            customerVM = this.DataContext as CustomerDetailsViewModel;
            //NavigateContext is null in the Constructor.
        }

        #region CustomerID
        private int CustomerID
        {
            get
            {
                int paramValue = 0;

                const string paramName = "CustomerID";
                string test = NavigationContext.QueryString [ paramName ];
                if ( NavigationContext.QueryString.ContainsKey ( paramName ) )
                    int.TryParse ( NavigationContext.QueryString [ paramName ], out paramValue );
                return paramValue;
            }
        }
        #endregion

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo ( NavigationEventArgs e )
        {
            
            customerVM.LoadCustomer ( CustomerID );
            
        }

        

       

    }
}
